package cn.tedu.logistics.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.tedu.logistics.bean.CarType;
import cn.tedu.logistics.service.CarTypeService;

@Controller
public class CarTypeController {
	@Autowired
	private CarTypeService service;
	
	@RequestMapping("/carType")
	public String CarType(ModelMap map) {
		List<CarType> carTypes=service.findCarType();
		map.addAttribute("carType", carTypes);
		return "carType";
	}
	@RequestMapping("/toaddcarType")
	public String toAddReader() {
		return "addCarType";
	}
	@RequestMapping("/addcarType")
	public String addCarType(CarType carType) {
//		readerType readerType=new readerType();
//		readerType.setId(id);
//		readerType.setCalling(calling);
//		readerType.setNumber(number);
		service.addCarType(carType);
		return "redirect:carType";
	}
	@RequestMapping("/delcarType")
	public String delCarType(Integer carTypeId) {
		service.delCarType(carTypeId);
		return "redirect:carType";
	}
	//跳转到修改页面
	@RequestMapping("/toupdcarType")
	public String toUpdCarType(Integer carTypeId,ModelMap map) {//存疑
		CarType carType=service.selectById(carTypeId);
		map.addAttribute("carType", carType);
		return "updcarType";//这个是jsp页面
	}
	@RequestMapping("/updcarType")
	public String updCarType(CarType carType) {
//		readerType readerType=new readerType();
//		readerType.setId(id);
//		readerType.setCalling(calling);
//		readerType.setNumber(number);
		service.updateCarType(carType);
		return "redirect:carType";
	}
}
